package main.war.city.building;

public class Loc implements Comparable<Loc>{
	private int x;
	private int y;
	private int z;
	public Loc(int x,int y,int z){
		this.x=x;
		this.y=y;
		this.z=z;
	}
	public int getX(){
		return x;
	}
	public int getY(){
		return y;
	}
	public int getZ(){
		return z;
	}
	public void setX(int x) {
		this.x = x;
	}
	public void setY(int y) {
		this.y = y;
	}
	public void setZ(int z) {
		this.z = z;
	}
	@Override
	public int hashCode(){
		return x+y+z;
	}
	@Override
	public boolean equals(Object o){
		if(o==null)return false;
		if(!(o instanceof Loc))return false;
		Loc l = (Loc) o;
		if(this.x==l.getX()&&this.y==l.getY()&&this.z==l.getZ())return true;
		return false;
	}
	@Override
	public String toString(){
		return "["+x+"]"+"["+y+"]"+"["+z+"]";
	}
	
	@Override
	public int compareTo(Loc l2) {
		int i = this.getY()-l2.getY();
		if(i!=0)return i;
		i = this.getX()-l2.getX();
		if(i!=0)return i;
		i = this.getZ()-l2.getZ();
		if(i!=0)return i;
		return 0;
	}
}
